package com.mz.ozy.widget;

import android.graphics.Rect;
import android.view.View;

import androidx.recyclerview.widget.RecyclerView;

/**
 * Created by Administrator on 2019/3/14.
 */

public class CommentDecoration extends RecyclerView.ItemDecoration {

    private int hspace;
    private int vspace;

    public CommentDecoration(int hspace, int vspace) {
        this.hspace = hspace;
        this.vspace = vspace;
    }

    @Override
    public void getItemOffsets(Rect outRect, View view,
                               RecyclerView parent, RecyclerView.State state) {
        if (parent.getChildAdapterPosition(view) ==
                parent.getLayoutManager().getChildCount() - 1) {
            outRect.right = 0;
        } else {
            outRect.right = hspace;
        }
        outRect.top = vspace;
    }

}
